package com.supply.dl.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.supply.dl.R;

/**
 * 扫描二维码
 */
public class ScanActivity extends BaseActivity {

    @butterknife.BindView(R.id.scan_view)
    public com.journeyapps.barcodescanner.DecoratedBarcodeView decoratedBarcodeView;
    private com.journeyapps.barcodescanner.CaptureManager captureManager;

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_scan;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitleShow(getResourcesString(R.string.supply_scan));
        showLeftBack();
        captureManager = new com.journeyapps.barcodescanner.CaptureManager(this, decoratedBarcodeView);
        captureManager.initializeFromIntent(getIntent(), savedInstanceState);
        captureManager.decode();
    }

    @Override
    protected void onPause() {
        super.onPause();
        captureManager.onPause();
    }

    @Override
    public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
        return decoratedBarcodeView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onResume() {
        super.onResume();
        captureManager.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        captureManager.onDestroy();
    }

}
